package com.vca.admin.controller;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vca.common.request.GiveAwayToUserRequest;
import com.vca.common.request.UserEditRequest;
import com.vca.common.result.CommonResult;
import com.vca.common.utils.SendSmsUtilsProxy;
import com.vca.common.vo.TemplateMessageVo;
import com.vca.service.service.UserService;
import com.vca.service.service.VcaOrderService;
import com.vca.service.service.WechatNewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * 赠送课程/讲座/展览API
 *
 * @author chenbing
 * @date 2022/11/24   11:04
 */
@Slf4j
@RestController("IndexController")
@RequestMapping("api/admin/index")
@Api(tags = "Index-API控制器")
public class IndexController {

    @Autowired
    private VcaOrderService vcaOrderService;

    /**
     * @Description:赠送课程/讲座/展览
     * @Author: chenBing
     * @Date: 2022/11/24
     */
    @PreAuthorize("hasAuthority('admin:index:send:course:talk:exhibition')")
    @ApiOperation(value = "赠送课程/讲座/展览")
    @PostMapping(value = "/send/course/talk/exhibition")
    public CommonResult<String> send(
            @Validated @RequestBody GiveAwayToUserRequest request
    ) {
        if (vcaOrderService.send(request)) {
            return CommonResult.success();
        }
        return CommonResult.failed();
    }
}
